package org.nnxy.foodboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.nnxy.foodboot.entity.RecipeSimilarity;

import java.util.List;

/**
 * 食谱相似度Mapper接口
 */
@Mapper
public interface RecipeSimilarityMapper extends BaseMapper<RecipeSimilarity> {
    
    /**
     * 获取与指定食谱最相似的食谱ID列表
     */
    @Select("SELECT recipe_id2 FROM recipe_similarity " +
            "WHERE recipe_id1 = #{recipeId} AND del_flag = '0' " +
            "ORDER BY overall_similarity DESC LIMIT #{limit}")
    List<Integer> getSimilarRecipeIds(@Param("recipeId") Integer recipeId, @Param("limit") Integer limit);
    
    /**
     * 获取与指定食谱相似的食谱ID列表（使用taste_similarity）
     */
    @Select("SELECT recipe_id2 FROM recipe_similarity " +
            "WHERE recipe_id1 = #{recipeId} AND del_flag = '0' " +
            "ORDER BY taste_similarity DESC LIMIT #{limit}")
    List<Integer> getSimilarTasteRecipeIds(@Param("recipeId") Integer recipeId, @Param("limit") Integer limit);
    
    /**
     * 获取与指定食谱相似的食谱ID列表（使用nutrition_similarity）
     */
    @Select("SELECT recipe_id2 FROM recipe_similarity " +
            "WHERE recipe_id1 = #{recipeId} AND del_flag = '0' " +
            "ORDER BY nutrition_similarity DESC LIMIT #{limit}")
    List<Integer> getSimilarNutritionRecipeIds(@Param("recipeId") Integer recipeId, @Param("limit") Integer limit);
} 